<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
    <STYLE>
        .cla1 {
            FONT-SIZE: 12px;
            COLOR: #4b4b4b;
            LINE-HEIGHT: 18px;
            TEXT-DECORATION: none
        }

        .login_msg {
            font-family: serif;
        }

        .login_msg .msg {
            background-color: #acf;
        }

        .login_msg .btn {
            background-color: #9be;
            width: 73px;
            font-size: 18px;
            font-family: 微软雅黑;
        }
    </STYLE>

    <TITLE></TITLE>
    <script type="text/javascript">
        if (self != top) {
            top.location = self.location;
        }
    </script>
    <META http-equiv=Content-Type content="text/html; charset=utf-8">
    <LINK href="../../css/style.css" type=text/css rel=stylesheet>
    <META content="MSHTML 6.00.2600.0" name=GENERATOR>
</HEAD>
<BODY leftMargin=0 topMargin=0 marginwidth="0" marginheight="0" background="../../images/rightbg.jpg">
<div ALIGN="center">
    <table border="0" width="1140px" cellspacing="0" cellpadding="0" id="table1">
        <tr>
            <td height="193"></td>

        </tr>
        <tr align="center">

            <td class="login_msg" width="400">
                <font size="6" color="#ffffff">
                    欢迎使用CRM系统
                </font>
                <br/>
                <br/>
                <font color="#ff0000" id="error">

                </font>
                <br/>
                用户名：<input type="text" name="loginName" class="msg"/><br/><br/>
                密&nbsp;码：<input type="password" class="msg" name="loginPwd"/><br/><br/>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button onclick="clickBtn()">登录</button>
            </td>
        </tr>
    </table>
    <script src="../../js/jquery-3.2.1.js"></script>
    <script type="text/javascript">
        function clickBtn() {
            var name = $("input[name='loginName']").val();
            var pwd = $("input[name='loginPwd']").val();
            if (name == "" || pwd == "" || name == null || pwd == null) {
                alert("账号密码不能为空！")
            } else {
                $.ajax({
                    url: "/loginsubmit",
                    type: "post",
                    data: {
                        loginName: name,
                        loginPwd: pwd
                    },
                    success: function (result) {
                        if (result.msg === "登陆成功") {
                            window.location.href = "/frame";
                        } else {
                            $("#error").html("账号或密码错误");
                        }
                    },
                    error: function () {
                        alert("错误")
                    }
                })
            }
        }
    </script>
</div>
</BODY>
</HTML>